import Vue from 'vue';
import VueRouter from 'vue-router';
import store from "./store.js";
import Frame from "../src/components/frame.vue";

import {
	RouterTabRoutes
} from 'vue-router-tab';

const importPage = view => () =>
	import(`../page/${view}.vue`)

Vue.use(VueRouter);

const pageRouters = [{
		path: '/', // 默认页和父级路由一致
		name: 'index',
		component: importPage('index'),
		meta: {
			title: '工作台' // 页签标题
		}
	},
	{
		path: '/user',
		name: 'user',
		component: importPage('user/list'),
		meta: {
			title: '用户列表' // 页签标题
		}
	},
	{
		path: '/role',
		name: 'role',
		component: importPage('role/list'),
		meta: {
			title: '角色列表' // 页签标题
		}
	},
	{
		path: '/permission',
		name: 'permission',
		component: importPage('permission/list'),
		meta: {
			title: '权限列表' // 页签标题
		}
	},

	{
		path: '/dept',
		name: 'dept',
		component: importPage('dept/list'),
		meta: {
			title: '部门列表' // 页签标题
		}
	},
	{
		path: '/dept/info',
		name: 'dept_info',
		component: importPage('dept/detail'),
		meta: {
			title: '部门详细' // 页签标题
		}
	},

	{
		path: '/emp',
		name: 'emp',
		component: importPage('emp/list'),
		meta: {
			title: '员工列表' // 页签标题
		}
	},
	{
		path: '/emp/info',
		name: 'emp_info',
		component: importPage('emp/detail'),
		meta: {
			title: '员工详细' // 页签标题
		}
	},

	{
		path: '/dict',
		name: 'dict_list',
		component: importPage('dict/list'),
		meta: {
			title: '字典列表' // 页签标题
		}
	},
	
	
	{
		path: '/client',
		name: 'client',
		component: importPage('client/list'),
		meta: {
			title: '客户列表' // 页签标题  
		}
	},
	
	{
		path: '/client/detail',
		name: 'client_detail',
		component: importPage('client/detail'),
		meta: {
			title: '客户详细' // 页签标题   
		}
	},
	
	
	
	{
		path: '/store',
		name: 'store',
		component: importPage('store/list'),
		meta: {
			title: '门店列表' // 页签标题  
		}
	},
	{
		path: '/store/detail',
		name: 'store_detail',
		component: importPage('store/detail'),
		meta: {
			title: '门店详细' // 页签标题  颖姐
		}
	},
	{
		path: '/store/new',
		name: 'store_new',
		component: importPage('store/new'),
		meta: {
			title: '门店新增' // 页签标题  
		}
	},
	
	
	{
		path: '/room',
		name: 'room',
		component: importPage('room/list'),
		meta: {
			title: '房间列表' // 页签标题 成哥
		}
	},
	{
		path: '/room/detail',
		name: 'room_detail',
		component: importPage('room/detail'),
		meta: {
			title: '房间详细' // 页签标题 成哥
		}
	},
	
	{
		path: '/dz',
		name: 'dz',
		component: importPage('dz/list'),
		meta: {
			title: '店长列表' // 页签标题 颖姐
		}
	},
	{
		path: '/dz/detail',
		name: 'dz_detail',
		component: importPage('dz/detail'),
		meta: {
			title: '店长详细' // 页签标题 颖姐
		}
	},
	
	{
		path: '/jl',
		name: 'jl',
		component: importPage('jl/list'),
		meta: {
			title: '教练列表' // 页签标题 硕哥
		}
	},
	{
		path: '/jl/detail',
		name: 'jl_detail',
		component: importPage('jl/detail'),
		meta: {
			title: '教练详细' // 页签标题 硕哥
		}
	},
	
	{
		path: '/kc',
		name: 'kc',
		component: importPage('kc/list'),
		meta: {
			title: '课程列表' // 页签标题 仕哥
		}
	},
	{
		path: '/kc/detail',
		name: 'kc_detail',
		component: importPage('kc/detail'),
		meta: {
			title: '课程详细' // 页签标题 仕哥
		}
	},
	
	{
		path: '/yyjl',
		name: 'yyjl',
		component: importPage('yyjl/list'),
		meta: {
			title: '场地预约列表' // 页签标题 怡姐
		}
	},
	{
		path: '/yyjl/detail',
		name: 'yyjl_detail',
		component: importPage('yyjl/detail'),
		meta: {
			title: '场地预约详细' // 页签标题 怡姐
		}
	},
	
	
	{
		path: '/kctp',
		name: 'kctp',
		component: importPage('kctp/list'),
		meta: {
			title: '课程分类列表' // 页签标题
		}
	},
	{
		path: '/kctp/detail',
		name: 'kctp_detail',
		component: importPage('kctp/detail'),
		meta: {
			title: '课程分类详细' // 页签标题
		}
	},
	{
		path: '/kctp/new',
		name: 'kctp_new',
		component: importPage('kctp/new'),
		meta: {
			title: '课程分类新增' // 页签标题
		}
	},
	
	
	{
		path: '/dztkjl',
		name: 'dztkjl',
		component: importPage('dztkjl/list'),
		meta: {
			title: '店长提款列表' // 页签标题 怡姐
		}
	},
	{
		path: '/dztkjl/detail',
		name: 'dztkjl_detail',
		component: importPage('dztkjl/detail'),
		meta: {
			title: '店长提款详细' // 页签标题 怡姐
		}
	},
	
	{
		path: '/jltkjl',
		name: 'jltkjl',
		component: importPage('jltkjl/list'),
		meta: {
			title: '教练提款列表' // 页签标题 怡姐
		}
	},
	{
		path: '/jltkjl/detail',
		name: 'jltkjl_detail',
		component: importPage('jltkjl/detail'),
		meta: {
			title: '教练提款详细' // 页签标题 怡姐
		}
	},
	
	{
		path: '/bm',
		name: 'bm',
		component: importPage('bm/list'),
		meta: {
			title: '报名列表' // 页签标题 骏哥
		}
	},
	{
		path: '/bm/detail',
		name: 'bm_detail',
		component: importPage('bm/detail'),
		meta: {
			title: '报名详细' // 页签标题 骏哥
		}
	},
	
	
	{
		path: '/skjl',
		name: 'skjl',
		component: importPage('skjl/list'),
		meta: {
			title: '上课记录列表' // 页签标题 斌哥
		}
	},
	{
		path: '/skjl/detail',
		name: 'skjl_detail',
		component: importPage('skjl/detail'),
		meta: {
			title: '上课记录详细' // 页签标题 斌哥
		}
	},
	
	{
		path: '/hylx',
		name: 'hylx',
		component: importPage('hylx/list'),
		meta: {
			title: '会员类型列表' // 页签标题 雷哥
		}
	},
	{
		path: '/hylx/detail',
		name: 'hylx_detail',
		component: importPage('hylx/detail'),
		meta: {
			title: '会员类型详细' // 页签标题 雷哥
		}
	},
	
	
	{
		path: '/hy',
		name: 'hy',
		component: importPage('hy/list'),
		meta: {
			title: '会员列表' // 页签标题 霞姐
		}
	},
	{
		path: '/hy/detail',
		name: 'hy_detail',
		component: importPage('hy/detail'),
		meta: {
			title: '会员详细' // 页签标题 霞姐
		}
	},
	
	{
		path: '/fzjl',
		name: 'fzjl',
		component: importPage('fzjl/list'),
		meta: {
			title: '分账记录列表' // 页签标题
		}
	},
	{
		path: '/fzjl/detail',
		name: 'fzjl_detail',
		component: importPage('fzjl/detail'),
		meta: {
			title: '分账详细' // 页签标题
		}
	},
	{
		path: '/settings/homepage',
		name: 'settings_homepage',
		component : importPage('settings/homepage'),
		meta: {
			title : '系统设置'
		}
	},
	{
		path: '/settings/shxx',
		name: 'shxx',
		component : importPage('settings/shxx'),
		meta: {
			title : '商户信息'
		}
	},
	{
		path: '/settings/sm',
		name: 'sm',
		component : importPage('settings/sm'),
		meta: {
			title : '条款声明'
		}
	},
	{
		path: '/settings/tjlx',
		name: 'tjlx',
		component : importPage('settings/tjlx'),
		meta: {
			title : '推荐类型'
		}
	},
	{
		path: '/settings/ptgl',
		name: 'ptgl',
		component : importPage('settings/ptgl'),
		meta: {
			title : '平台管理'
		}
	},
	{
		path: '/settings/xcxxx',
		name: 'xcxxx',
		component : importPage('settings/xcxxx'),
		meta: {
			title : '小程序信息'
		}
	}
];






const detailRouters = {
	'user_new': {
		name: 'user_new',
		component: importPage('user/new'),
		meta: {
			title: '用户新增' // 页签标题
		}
	},
	'user_detail': {
		name: 'user_detail',
		component: importPage('user/detail'),
		meta: {
			title: '用户详情', // 页签标题
		}
	},
	'role_new': {
		name: 'role_new',
		component: importPage('role/new'),
		meta: {
			title: '新增角色' // 页签标题
		}
	},
	'role_detail': {
		name: 'role_detail',
		component: importPage('role/detail'),
		meta: {
			title: '角色详细' // 页签标题
		}
	},
	'permission_new': {
		name: 'permission_new',
		component: importPage('permission/new'),
		meta: {
			title: '新增权限' // 页签标题
		}
	},
	'permission_detail': {
		name: 'permission_detail',
		component: importPage('permission/detail'),
		meta: {
			title: '权限详细' // 页签标题
		}
	},

	'dept_new': {
		name: 'dept_new',
		component: importPage('dept/new'),
		meta: {
			title: '新增部门' // 页签标题
		}
	},
	'job_detail': {
		name: 'job_detail',
		component: importPage('job/detail'),
		meta: {
			title: '职位详细' // 页签标题
		}
	},
	'job_new': {
		name: 'job_new',
		component: importPage('job/new'),
		meta: {
			title: '职位新增' // 页签标题
		}
	},


	'flow_new': {
		name: 'flow_new',
		component: importPage('flow/new'),
		meta: {
			title: '新增流程' // 页签标题
		}
	},

	'flow_detail': {
		name: 'flow_detail',
		component: importPage('flow/detail'),
		meta: {
			title: '模板详细' // 页签标题
		}
	},

	'emp_new': {
		name: 'emp_new',
		component: importPage('emp/new'),
		meta: {
			title: '新增员工' // 页签标题
		}
	},
	
	'dict_new': {
		name: 'dict_new',
		component: importPage('dict/new'),
		meta: {
			title: '新增字典' // 页签标题
		}
	},
	
	'dict_detail': {
		name: 'dict_detail',
		component: importPage('dict/detail'),
		meta: {
			title: '字典详细' // 页签标题
		}
	},
	
	
	
	'mj_new': {
		name: 'mj_new',
		component: importPage('mj/new'),
		meta: {
			title: '新增门禁' // 页签标题
		}
	},
	
	'mj_detail': {
		name: 'mj_detail',
		component: importPage('mj/detail'),
		meta: {
			title: '门禁详细' // 页签标题
		}
	},
	
	
	// 'set_system': {
	// 	name: 'set_system',
	// 	component: importPage('set/system'),
	// 	meta: {
	// 		title: '系统设置' // 页签标题
	// 	}
	// },
	// 'shxx' : {
	// 	name: 'shxx',
	// 	component: importPage('settings/shxx'),
	// 	meta: {
	// 		title: '商户信息' // 页签标题
	// 	}
	// },
	// 'ptgl' : {
	// 	name: 'ptgl',
	// 	component: importPage('settings/ptgl'),
	// 	meta: {
	// 		title: '平台管理' // 页签标题
	// 	}
	// },
	// 'xcxxx' : {
	// 	name: 'xcxxx',
	// 	component: importPage('settings/xcxxx'),
	// 	meta: {
	// 		title: '小程序信息' // 页签标题
	// 	}
	// },
	'set_divrule': {
		name: 'set_divrule',
		component: importPage('set/divrule'),
		meta: {
			title: '分账规则详细' // 页签标题
		}
	},
	
};


const routes = [{
	path: '/',
	component: Frame,
	meta: {
		title: '主页' // 页签标题
	},
	children: pageRouters
}];

const router = new VueRouter({
	routes,
	pageRouters,
	detailRouters
});

router.detail = {
	open: param => {
		store.commit("openDetail", param);
	},
	close: param => {
		store.commit("closeDetail");
	}
}

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
}

export default router;
